/**
 * 2017年6月29日
 */
package org.textplantform.common.core.mq;

import java.io.IOException;
import java.util.Properties;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.textplantform.common.api.mq.PlantformTextConsumer;
import org.textplantform.common.api.mq.PlantformTextConsumerFactory;

/**
 * @author Alex
 *
 */
public class KafkaConsumerFactory implements PlantformTextConsumerFactory{
	private static Properties props = new Properties();
	static {
		try {
			props.load(KafkaConsumerFactory.class.getClassLoader().getResourceAsStream("meta/mq-consumer.properties"));
		} catch (IOException e) {
			throw new RuntimeException(e.getMessage(),e);
		}
	}
	public static PlantformTextConsumer<ConsumerRecord<String,String>> getConsumer(String topic){
		KafkaConsumer<String, String> kc = new KafkaConsumer<>(props);
		return new DefaultPlantformKafkaConsumer(kc, topic);
	}
}
